package com.log.controller;

import com.log.common.vo.ResultVo;
import com.log.pojo.LogDepot;
import com.log.service.LogDepotService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author wjy
 * @create 2023-10-2023/10/21 20:16
 */

@RestController
@RequestMapping("/depot")
@Api(tags = "仓库管理",value = "")
public class LogDepotController {
    @Autowired
    private LogDepotService logDepotService;

    @ApiOperation("添加分仓信息")
    @PostMapping("/add")
    public ResultVo addDepot(@RequestBody LogDepot logDepot)
    {
        return logDepotService.addLogDepot(logDepot);
    }

    @ApiOperation("修改分仓信息")
    @PutMapping("/update")
    public ResultVo updateDepot(@RequestBody LogDepot logDepot)
    {
        return logDepotService.updateLogDepot(logDepot);
    }

    @ApiOperation("删除分仓信息")
    @DeleteMapping("/delete")
    public ResultVo deleteDepot(int id)
    {
        return logDepotService.deleteLogDepot(id);
    }

    @ApiOperation("分页查询接口")
    @GetMapping("/page")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(dataType = "int",name = "pageNum",value = "当前的页码",required = true),
                    @ApiImplicitParam(dataType = "int",name = "limit",value = "每页显示条数",required = true),

            }
    )
    public ResultVo listPage(int pageNum,int limit){
        return logDepotService.getLogDepotByPage(pageNum,limit);
    }

    @ApiOperation("通过ID查询单条记录")
    @GetMapping("/{id}")
    public ResultVo getById(@PathVariable("id") int id){

        return  logDepotService.getLogDepotById(id);
    }

    @ApiOperation("查询全部仓库信息")
    //通过id删除
    @GetMapping("/selectAll")
    public ResultVo delbyid(){
        return logDepotService.getAll();
    }
}
